<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>自己创建一个Math对象</title>
        <script type="text/javascript">
            // 有属性PI,两个方法，计算最大值和最小值
            let myMath  = {
                PI: 3.1415926,
                max: function() {
                    // arguments 伪数组对象
                    let max = arguments[0];
                    for (let i = 1; i < arguments.length; i++) {
                        if (max < arguments[i]) {
                            max = arguments[i];
                        }
                    }
                    if(typeof max != Number){
                        max = Number(max);
                    }
                    if(arguments.length == 0){
                        max = -Infinity;
                    }
                    return max;
                },
                min: function(){
                    let min = arguments[0];
                    for (let i = 1; i < arguments.length; i++) {
                        if (min > arguments[i]) {
                            min = arguments[i];
                        }
                    }
                    if(typeof min != Number){
                        min = Number(min);
                    }
                    if(arguments.length == 0){
                        min = -Infinity;
                    }
                    return min;
                }
            };
            console.log(Math.PI);
            console.log(Math.max(1, 5, 9)); // 9
            console.log(Math.max()); // undefined
            console.log(Math.max('12', 11)); // 12
            console.log(Math.max('abc', 1)); // NaN
            console.log(Math.max(true, null)); // 1

            // 练习：优化这个max和min 函数，和Math的方法行为一致

        </script>
    </head>
    <body>
    </body>
</html>
